package com.example;

import com.example.config.ThreadPoolConfig;
import com.example.service.TimeService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AnnotationIocApplication {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = 
            new AnnotationConfigApplicationContext(ThreadPoolConfig.class, TimeService.class);
        
        TimeService timeService = context.getBean(TimeService.class);
        
        System.out.println("主线程: " + Thread.currentThread().getName() + " 开始执行");
        
        timeService.printCurrentTimeRepeatedly(10);
       
        timeService.countdown(60);
        
        System.out.println("主线程: " + Thread.currentThread().getName() + " 继续执行其他任务");
        
        try {
            Thread.sleep(15000); // 等待15秒
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        context.close();
    }
}